﻿<Activity mc:Ignorable="sads sap sap2010" x:Class="HybridLab.Workflow.Activities.CustomActivities.RestoreHybridLabEnvironmentSnapshots"
 xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities"
 xmlns:hvi="clr-namespace:HybridLab.Virtual.Interfaces;assembly=HybridLab.Virtual.Interfaces"
 xmlns:local="clr-namespace:HybridLab.Workflow.Activities.Info"
 xmlns:local1="clr-namespace:HybridLab.Workflow.Activities.CodeActivities"
 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
 xmlns:mca="clr-namespace:Microsoft.CSharp.Activities;assembly=System.Activities"
 xmlns:mtbc="clr-namespace:Microsoft.TeamFoundation.Build.Client;assembly=Microsoft.TeamFoundation.Build.Client"
 xmlns:mtbwa="clr-namespace:Microsoft.TeamFoundation.Build.Workflow.Activities;assembly=Microsoft.TeamFoundation.Build.Workflow"
 xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities"
 xmlns:sads="http://schemas.microsoft.com/netfx/2010/xaml/activities/debugger"
 xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation"
 xmlns:sap2010="http://schemas.microsoft.com/netfx/2010/xaml/activities/presentation"
 xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib"
 xmlns:sco="clr-namespace:System.Collections.ObjectModel;assembly=mscorlib"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <x:Members>
    <x:Property Name="HybridLabEnvironment" Type="InArgument(local:HybridLabEnvironment)" />
  </x:Members>
  <sap2010:ExpressionActivityEditor.ExpressionActivityEditor>C#</sap2010:ExpressionActivityEditor.ExpressionActivityEditor>
  <sap2010:WorkflowViewState.IdRef>HybridLab.Workflow.Activities.CustomActivities.RestoreHybridLabEnvironmentSnapshots_1</sap2010:WorkflowViewState.IdRef>
  <TextExpression.NamespacesForImplementation>
    <sco:Collection x:TypeArguments="x:String">
      <x:String>System</x:String>
      <x:String>System.Collections.Generic</x:String>
      <x:String>System.Data</x:String>
      <x:String>System.Linq</x:String>
      <x:String>System.Text</x:String>
      <x:String>HybridLab.Workflow.Activities.Info</x:String>
      <x:String>Microsoft.TeamFoundation.Build.Workflow.Activities</x:String>
    </sco:Collection>
  </TextExpression.NamespacesForImplementation>
  <TextExpression.ReferencesForImplementation>
    <sco:Collection x:TypeArguments="AssemblyReference">
      <AssemblyReference>Microsoft.TeamFoundation.Build.Client</AssemblyReference>
      <AssemblyReference>Microsoft.TeamFoundation.Build.Common</AssemblyReference>
      <AssemblyReference>Microsoft.TeamFoundation.Build.Workflow</AssemblyReference>
      <AssemblyReference>Microsoft.TeamFoundation.Client</AssemblyReference>
      <AssemblyReference>Microsoft.TeamFoundation.Lab.Client</AssemblyReference>
      <AssemblyReference>Microsoft.TeamFoundation.Lab.Workflow.Activities</AssemblyReference>
      <AssemblyReference>Microsoft.TeamFoundation.TestManagement.Client</AssemblyReference>
      <AssemblyReference>Microsoft.TeamFoundation.WorkItemTracking.Client</AssemblyReference>
      <AssemblyReference>Microsoft.WizardFramework</AssemblyReference>
      <AssemblyReference>PresentationCore</AssemblyReference>
      <AssemblyReference>PresentationFramework</AssemblyReference>
      <AssemblyReference>System</AssemblyReference>
      <AssemblyReference>System.Activities</AssemblyReference>
      <AssemblyReference>System.Activities.Presentation</AssemblyReference>
      <AssemblyReference>System.Core</AssemblyReference>
      <AssemblyReference>System.Drawing</AssemblyReference>
      <AssemblyReference>System.ServiceModel</AssemblyReference>
      <AssemblyReference>System.ServiceModel.Activities</AssemblyReference>
      <AssemblyReference>System.Windows</AssemblyReference>
      <AssemblyReference>System.Windows.Forms</AssemblyReference>
      <AssemblyReference>System.Xaml</AssemblyReference>
      <AssemblyReference>System.Xml.Linq</AssemblyReference>
      <AssemblyReference>System.Data.DataSetExtensions</AssemblyReference>
      <AssemblyReference>Microsoft.CSharp</AssemblyReference>
      <AssemblyReference>System.Data</AssemblyReference>
      <AssemblyReference>System.Xml</AssemblyReference>
      <AssemblyReference>WindowsBase</AssemblyReference>
      <AssemblyReference>HybridLab.Virtual.Interfaces</AssemblyReference>
      <AssemblyReference>mscorlib</AssemblyReference>
      <AssemblyReference>HybridLab.Workflow.Activities</AssemblyReference>
    </sco:Collection>
  </TextExpression.ReferencesForImplementation>
  <Sequence sap2010:WorkflowViewState.IdRef="Sequence_1">
    <Sequence.Variables>
      <Variable x:TypeArguments="hvi:IVirtualHost" Name="virtualHost" />
    </Sequence.Variables>
    <local1:GetHybridLabVirtualHost sap2010:WorkflowViewState.IdRef="GetHybridLabVirtualHost_1">
      <local1:GetHybridLabVirtualHost.HybridLabEnvironment>
        <InArgument x:TypeArguments="local:HybridLabEnvironment">
          <mca:CSharpValue x:TypeArguments="local:HybridLabEnvironment">HybridLabEnvironment</mca:CSharpValue>
        </InArgument>
      </local1:GetHybridLabVirtualHost.HybridLabEnvironment>
      <local1:GetHybridLabVirtualHost.Result>
        <OutArgument x:TypeArguments="hvi:IVirtualHost">
          <mca:CSharpReference x:TypeArguments="hvi:IVirtualHost">virtualHost</mca:CSharpReference>
        </OutArgument>
      </local1:GetHybridLabVirtualHost.Result>
    </local1:GetHybridLabVirtualHost>
    <ParallelForEach x:TypeArguments="hvi:IVirtualMachine" DisplayName="Restore each machine's snapshot in parallel" sap2010:WorkflowViewState.IdRef="ParallelForEach`1_1">
      <ParallelForEach.Values>
        <InArgument x:TypeArguments="scg:IEnumerable(hvi:IVirtualMachine)">
          <mca:CSharpValue x:TypeArguments="scg:IEnumerable(hvi:IVirtualMachine)">virtualHost.GetVMs()</mca:CSharpValue>
        </InArgument>
      </ParallelForEach.Values>
      <ActivityAction x:TypeArguments="hvi:IVirtualMachine">
        <ActivityAction.Argument>
          <DelegateInArgument x:TypeArguments="hvi:IVirtualMachine" Name="vm" />
        </ActivityAction.Argument>
        <Sequence sap2010:WorkflowViewState.IdRef="Sequence_2">
          <Sequence.Variables>
            <Variable x:TypeArguments="local:HybridLabVMSnapshotInfo" Name="snapshot" />
          </Sequence.Variables>
          <Assign sap2010:WorkflowViewState.IdRef="Assign_1">
            <Assign.To>
              <OutArgument x:TypeArguments="local:HybridLabVMSnapshotInfo">
                <mca:CSharpReference x:TypeArguments="local:HybridLabVMSnapshotInfo">snapshot</mca:CSharpReference>
              </OutArgument>
            </Assign.To>
            <Assign.Value>
              <InArgument x:TypeArguments="local:HybridLabVMSnapshotInfo">
                <mca:CSharpValue x:TypeArguments="local:HybridLabVMSnapshotInfo">HybridLabEnvironment.EnvironmentSnapshotInfo.Snapshots.FirstOrDefault(s =&gt; s.MachineName.Equals(vm.Name, StringComparison.OrdinalIgnoreCase))</mca:CSharpValue>
              </InArgument>
            </Assign.Value>
          </Assign>
          <If DisplayName="If this machine needs a restore" sap2010:WorkflowViewState.IdRef="If_1">
            <If.Condition>
              <InArgument x:TypeArguments="x:Boolean">
                <mca:CSharpValue x:TypeArguments="x:Boolean">snapshot != null &amp;&amp; !string.IsNullOrEmpty(snapshot.SnapshotName)</mca:CSharpValue>
              </InArgument>
            </If.Condition>
            <If.Then>
              <local1:RestoreVMSnapshotActivity sap2010:WorkflowViewState.IdRef="RestoreVMSnapshotActivity_1">
                <local1:RestoreVMSnapshotActivity.Machine>
                  <InArgument x:TypeArguments="hvi:IVirtualMachine">
                    <mca:CSharpValue x:TypeArguments="hvi:IVirtualMachine">vm</mca:CSharpValue>
                  </InArgument>
                </local1:RestoreVMSnapshotActivity.Machine>
                <local1:RestoreVMSnapshotActivity.SnapshotName>
                  <InArgument x:TypeArguments="x:String">
                    <mca:CSharpValue x:TypeArguments="x:String">snapshot.SnapshotName</mca:CSharpValue>
                  </InArgument>
                </local1:RestoreVMSnapshotActivity.SnapshotName>
              </local1:RestoreVMSnapshotActivity>
            </If.Then>
            <If.Else>
              <mtbwa:WriteBuildMessage sap2010:WorkflowViewState.IdRef="WriteBuildMessage_1" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces">
                <mtbwa:WriteBuildMessage.Importance>
                  <InArgument x:TypeArguments="mtbc:BuildMessageImportance">
                    <mca:CSharpValue x:TypeArguments="mtbc:BuildMessageImportance">Microsoft.TeamFoundation.Build.Client.BuildMessageImportance.Normal</mca:CSharpValue>
                  </InArgument>
                </mtbwa:WriteBuildMessage.Importance>
                <mtbwa:WriteBuildMessage.Message>
                  <InArgument x:TypeArguments="x:String">
                    <mca:CSharpValue x:TypeArguments="x:String">string.Format("Skipping restore snapshot for machine {0}", vm.Name)</mca:CSharpValue>
                  </InArgument>
                </mtbwa:WriteBuildMessage.Message>
              </mtbwa:WriteBuildMessage>
            </If.Else>
          </If>
        </Sequence>
      </ActivityAction>
    </ParallelForEach>
    <sads:DebugSymbol.Symbol>d3lDOlxsb2NhbFRGU1xDb2RlMTFcREVWXEh5YnJpZExhYlxIeWJyaWRMYWIuV29ya2Zsb3cuQWN0aXZpdGllc1xDdXN0b21BY3Rpdml0aWVzXFJlc3RvcmVIeWJyaWRMYWJFbnZpcm9ubWVudFNuYXBzaG90cy54YW1sEkMDlAEOAgEBRwVSJgIBLlMFkgEXAgECSgtKbwIBMk8LT2QCAS9WC1Z5AgErXQmQARQCAQNhC2wUAgEgbQuPARACAQRpEWn0AQIBJmQRZHQCASFwEXCYAQIBBXQPfzICARWCAQ+NASkCAQp3FXdgAgEbfBV8aAIBFooBFYoBlgECARCFARWFAakBAgEL</sads:DebugSymbol.Symbol>
  </Sequence>
  <sap2010:WorkflowViewState.ViewStateManager>
    <sap2010:ViewStateManager>
      <sap2010:ViewStateData Id="GetHybridLabVirtualHost_1" sap:VirtualizedContainerService.HintSize="516,22" />
      <sap2010:ViewStateData Id="Assign_1" sap:VirtualizedContainerService.HintSize="464,62" />
      <sap2010:ViewStateData Id="RestoreVMSnapshotActivity_1" sap:VirtualizedContainerService.HintSize="200,22" />
      <sap2010:ViewStateData Id="WriteBuildMessage_1" sap:VirtualizedContainerService.HintSize="200,22" />
      <sap2010:ViewStateData Id="If_1" sap:VirtualizedContainerService.HintSize="464,210">
        <sap:WorkflowViewStateService.ViewState>
          <scg:Dictionary x:TypeArguments="x:String, x:Object">
            <x:Boolean x:Key="IsExpanded">True</x:Boolean>
            <x:Boolean x:Key="IsPinned">False</x:Boolean>
          </scg:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
      </sap2010:ViewStateData>
      <sap2010:ViewStateData Id="Sequence_2" sap:VirtualizedContainerService.HintSize="486,436">
        <sap:WorkflowViewStateService.ViewState>
          <scg:Dictionary x:TypeArguments="x:String, x:Object">
            <x:Boolean x:Key="IsExpanded">True</x:Boolean>
          </scg:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
      </sap2010:ViewStateData>
      <sap2010:ViewStateData Id="ParallelForEach`1_1" sap:VirtualizedContainerService.HintSize="516,586" />
      <sap2010:ViewStateData Id="Sequence_1" sap:VirtualizedContainerService.HintSize="538,772">
        <sap:WorkflowViewStateService.ViewState>
          <scg:Dictionary x:TypeArguments="x:String, x:Object">
            <x:Boolean x:Key="IsExpanded">True</x:Boolean>
          </scg:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
      </sap2010:ViewStateData>
      <sap2010:ViewStateData Id="HybridLab.Workflow.Activities.CustomActivities.RestoreHybridLabEnvironmentSnapshots_1" sap:VirtualizedContainerService.HintSize="578,852" />
    </sap2010:ViewStateManager>
  </sap2010:WorkflowViewState.ViewStateManager>
</Activity>